<%@page contentType="text/html;charset=utf-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>   
<script type="text/javascript">

function pi_changechannel(obj)
{
    var channel = dijit.byId("deployed.channel").get("value");
    var url = "pi/deploy/changechannel.do";
    var content = "deployed.channel=" + channel;
    var objectid = "pi_projectlist";
    sendXMLHttpRequest(url, content, objectid); 
}

function pi_checkdeployed(obj, objectid)
{
	var plugin = document.getElementById("deployed.plugin").value;
    var channel = dijit.byId("deployed.channel").get("value");
    var project = dijit.byId("deployed.project").get("value");
    var version = dijit.byId("deployed.version").get("value");

    if (channel == null || channel == "" 
        || version == null || version == ""
        || project == null || project == "")
    	return;
    
    var url = "pi/deploy/check.do";
    var content = "deployed.plugin=" + plugin 
                + "&deployed.project=" + project
                + "&deployed.channel=" + channel
                + "&deployed.version=" + version;
    if (objectid == null || objectid == "")
        objectid = "pi_checkdeployed";
    sendXMLHttpRequest(url, content, objectid); 
}

function pi_savedeployed(type)
{
    if (document.getElementById("hasActionErrors"))
    {
        alert("选择错误！");
        return false;
    }
    var version = dijit.byId("deployed.version").get("value");
    var channel = dijit.byId("deployed.channel").get("value");
    var project = dijit.byId("deployed.project").get("value");
    if (channel == null || channel == "" 
        || version == null || version == ""
        || project == null || project == "")
    {
        alert("信息不完整！");
        return false;
    }
    
    if (document.getElementById("pluginfile").value == "")
    {
    	alert("没有选择文件");
    	return false;
    }

    if (!confirm("确定继续？"))
    {
        return false;
    }
    var url = "pi/deploy/save.do?type=" + type;
    /*alert(content);*/
    var objectid = "pi_deployed";
    postXMLHttpRequest(url, "myform", objectid); 
}
</script>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="5"></td>
    <td>   
  <form id="myform" name="myform" id="myform" enctype="multipart/form-data" 
        method="post" action="">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td colspan="3">
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/table_top_left.jpg" width="20" height="15" /></td>
            <td><img src="images/table_top_bg.jpg" width="770" height="15"/></td>
            <td align="right">
              <img src="images/table_top_right.jpg" width="20" height="15" /></td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td height="25" colspan="3" class="table_blue">
        <strong><img src="images/dot.jpg" width="13" height="9">部署信息</strong></td>
    </tr> 
    <tr>
      <td class="table_w1">&nbsp;<font color="red">(*)</font>渠道：</td>
      <td class="table_w2" colspan="2">&nbsp;
        <input type="hidden" id="deployed.id" name="deployed.id" value="<s:property value="deployed.id"/>" />
        <input type="hidden" id="deployed.plugin" name="deployed.plugin" value="<s:property value="deployed.plugin"/>" />        
        <select id="deployed.channel"  dojoType="dijit.form.FilteringSelect"
            name="deployed.channel" style="width:280px;" onchange="pi_changechannel(this)">
            <s:if test="deployed==null||deployed.id<=0">
            <option value="">请选择</option>
            </s:if>
           <s:if test="channels.size()>0">
           <s:iterator value="channels" status="stat1">
           <s:set name="cid" value="deployed.channel" />
           <option value="<s:property value="id" />" 
                <s:if test="id.equals(#cid)">selected</s:if> ><s:property value="name" /></option>
           </s:iterator>
           </s:if>
        </select>
      </td>
    </tr>
    <tr>
      <td class="table_w1">&nbsp;<font color="red">(*)</font>项目：</td>
      <td class="table_w2" colspan="2"><div id="pi_projectlist">
        <s:include value="_changechannel.jsp" /></div>
        <div id="pi_checkdeployed"></div>
      </td>
    </tr>
    <tr>
      <td class="table_w1">&nbsp;<font color="red">(*)</font>版本：</td>
      <td class="table_w2" colspan="2">&nbsp;
        <select id="deployed.version"  dojoType="dijit.form.FilteringSelect"
            name="deployed.version" style="width:280px;" onchange="pi_checkdeployed(this,'pi_checkversion');">
            <s:if test="deployed==null||deployed.id<=0">
            <option value="">请选择</option>
            </s:if>
           <s:if test="releaseds.size()>0">
           <s:iterator value="releaseds" status="stat1">
           <s:set name="ver" value="deployed.version" />
           <option value="<s:property value="version" />" 
                <s:if test="version.equals(#ver)">selected</s:if> ><s:property value="version" /></option>
           </s:iterator>
           </s:if>
        </select>
        <div id="pi_checkversion"></div>
      </td>
    </tr> 
    <tr>
      <td class="table_w1" align="center" width="20%">&nbsp;文件：</td>
      <td class="table_w2" colspan="2">&nbsp;
        <input type="file" id="pluginfile" name="pluginfile" size="60" /></td>
    </tr>  
    <tr>
      <td colspan="3" class="table_w1" align="center">
        <s:if test="type.equals('insert')" >
        <button id="btn2" dojoType="dijit.form.Button"
            onclick="pi_savedeployed('insert');">添加</button>
        </s:if>
        <s:else>
        <button id="btn2" dojoType="dijit.form.Button"
            onclick="pi_savedeployed('update');">修改</button>
        &nbsp;&nbsp;        
        <button id="btn3" dojoType="dijit.form.Button"
            onclick="pi_savedeployed('delete');">删除</button>
        </s:else>
      </td>      
    </tr>
    <tr> 
      <td colspan="3" background="images/table_bom_bg.jpg">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="images/table_bom_left.jpg" width="20" height="15"></td>
          <td></td>
          <td align="right">
            <img src="images/table_bom_right.jpg" width="20" height="15"></td>
        </tr>
        </table>
      </td>
    </tr>
  </table>  
  </form>
  </td>
  <td width="5"></td>
  </tr>
  </table>